package com.zr.Inquiry.meiju;

/**
 * Created by Liyiding on 2019/9/28.
 */
public enum CurrencyCodeEnum {
    RMB(0,"人民币"),MEIYUAN(1,"美元");

    private final String currencyCodeName;
    private final Integer currencyCodeValue;

    private CurrencyCodeEnum(Integer currencyCodeValue, String currencyCodeName)
    {
        this.currencyCodeName = currencyCodeName;
        this.currencyCodeValue = currencyCodeValue;
    }

    // 通过值取名称
    public static String getName(int currencyCodeValue) {
        for (CurrencyCodeEnum i : CurrencyCodeEnum.values()) {
            if (i.getCurrencyCodeValue() == currencyCodeValue) {
                return i.currencyCodeName;
            }
        }

        return null;
    }
    // 通过名称取值
    public static Integer getValue(String currencyCodeName) {
        for (CurrencyCodeEnum i : CurrencyCodeEnum.values())
            if (i.getCurrencyCodeName().equals(currencyCodeName)) {
                return i.getCurrencyCodeValue();
            }
        return null;
    }

    public String getCurrencyCodeName() {
        return currencyCodeName;
    }

    public Integer getCurrencyCodeValue() {
        return currencyCodeValue;
    }
}
